from sqlalchemy.orm import Session

from . import models, schemas


def get_items(db: Session, token, skip: int = 0, limit: int = 1000):
    return db.query(models.Item).filter_by(session_id=token).offset(skip).limit(limit).all()


def create_item(db: Session, item:schemas.ItemCreate):
    db_item = models.Item(mtype=item.mtype, session_id=item.token, msg=item.msg)
    db.add(db_item)
    db.commit()
    db.refresh(db_item)
    return db_item

